<include file="Public/head" />
<include file="Public/common_header" />
<style>
    .tanShang1 .daiJingW li .riqi {
    background: url(../images/yun_tubiao3.jpg) no-repeat 0 -120px;
}

.tanShang3{width:554px;height:220px; position:fixed; z-index:99;left:50%;top:50%;margin:-110px 0 0 -277px; background:#fff;border:solid 1px #20ab4f;border-radius:3px; display:none;}
.tanShang3 h3{height:38px; line-height:38px;border:solid 1px #ededee; background:#cecece;font-size:18px;color:#333; display:block; text-align:center;border-radius:3px;}
.tanShang3 ul li{ display:block; text-align:left;margin-bottom:20px; position:relative;}
.tanShang3 ul li span{float:left; display:block;height:28px; line-height:28px;width:60px; text-align:right;font-size:14px;color:#333;margin-right:18px;}
.tanShang3 ul li input{width:356px;float:left;height:26px;color:#333;line-height:26px;border:solid 1px #d2d2d2; display:block; text-align:center;}
.tanShang3 ul li .yuan{ position:absolute;right:85px;top:0;height:28px; line-height:28px; z-index:999;}
.tanShang3 ul li .shezhi{width:170px;height:30px; line-height:30px; text-align:center;border-radius:3px; background:#20ab4f;color:#fff;font-size:14px;border:none;float:left;margin:0 38px;}
.tanShang3 ul li .bushezhi{width:170px;height:30px; line-height:30px; text-align:center;border-radius:3px; background:#fff;color:#20ab4f;font-size:14px;border:none;float:left;border:solid 1px #20ab4f;}
#cx_bc_city{
         -moz-appearance: none;background: rgba(0, 0, 0, 0) url("http://img2.isou365.cn/paimai/yunying/images/sanjiao.jpg") no-repeat scroll 125px 5px;border: 1px solid #d7d7d7;color: #666;float: left;
    font-family: "微软雅黑";font-size: 12px;height: 24px;line-height: 24px;margin: 0 10px 10px 0;text-align: left;width: 149px;text-indent: 10px;
    }

</style>
<div class="mian">
    <include file="Public/sidebar" menu="cwgl.cjhd"  />
	<div class="mianR">

        <div class="shangPic"><img src="http://img1.isou365.cn/paimai/yunying/images/draw_pic.jpg" /></div>
        <div class="shangFrom clearfix">
            <div class="chang-ci">
                <input type="button" value="新建活动" id="xinjian1"/>
            </div>
            <div class="zhuang-tai">
                <input type="text" id="start_time" name="start_time" value="{$params.start_time}" placeholder="请选择开始时间" readonly /><em></em>            
            </div>
             <div class="zhuang-tai">
                <input type="text" id="end_time" name="end_time" value="{$params.end_time}" placeholder="请选择开始时间" readonly />
            </div>
                <select name="cx_bc_city" id="cx_bc_city">
                        <?php if ($is_hq): ?>
                         <option value="">请选择分公司</option>   
                        <?php endif ?>
                        <?php foreach ($bc_list as $k => $v): ?>
                            <option value="{$k}" >{$v}</option>
                        <?php endforeach ?>
                    </select>
        <div class="deng-ji" style="width:200px"><input type="text" name="keyword" value="" placeholder=" 活动ID、活动金额、活动名称" style="width:200px" /></div>
        <div class="shangSou"><input id="searchBtn" type="button" value="搜索" /></div>
        </div>

		<div class="listBox" id="listBox">

		</div>

        <!--新建弹出窗口-->
<!--         <div class="yunBei"></div> -->
        <div class="tanShang">
           <h3>新建抽奖活动</h3>
           <ul class="daiJingW">
                <li class="clearfix">
                   <span class="daiJing">活动名称</span>
                   <input type="text" name="rafflename" value="" placeholder="请输入活动名称" />
                </li>
                <li class="clearfix">
                   <span class="daiJing">总金额</span>
                   <input type="text" name="amount" value="" placeholder="请输入活动总金额"/>
                </li>
                <li class="clearfix">
                   <span class="daiJing">活动类型</span>
                   <select name="type" id="type" >
                        <option value="0">请选择活动类型</option>                       
                        <option value="1">现金直减</option>
                        <option value="2">抽代金券</option>
                    </select>
                </li>
                <li class="clearfix" style="display:none;">
                   <span class="daiJing">活动形式</span>
                   <select name="form" id="form" >
                        <option value="0">请选择活动形式</option>                       
                        <option value="1" selected="selected">大转盘</option>
                    </select>
                </li>
                <li class="clearfix">
                   <span class="daiJing">开始日期</span>
                   <input type="text" name="start_date" id="demoTime1" value="<?php echo date('Y-m-d H:i:s');?>"  placeholder="请选择活动开始日期" class="riqi" readonly />
                </li>
                <li class="clearfix">
                    <span class="daiJing">截止日期</span>
                    <input type="text" name="end_date" id="demoTime2"  value="<?php echo date('Y-m-d H:i:s');?>" placeholder="请选择活动结束日期"  class="riqi" readonly />
               </li>
                <li class="clearfix closing_date" style="display:none;">
                    <span class="daiJing">代金券截止日期</span>
                    <input type="text" name="coupon_end_date" id="demoTime5"  value="<?php echo date('Y-m-d');?>" placeholder="请选择代金券结束日期"  class="riqi" readonly />
               </li>
               <li class="clearfix">
                   <span class="daiJing">所属公司</span>
                   <select name="bc_city" id="bc_city" >
                        <?php if ($is_hq): ?>
                            <option value="">请选择所属公司</option>
                        <?php endif ?>
                        <foreach name="bc_list" item="v" key="k" >
                          <option value="{$k}">{$v}</option>
                        </foreach>
                    </select>
                </li>
               <li class="clearfix">
                   <input type="button" id="addRaffle" value="确定" class="queding" />
                   <input type="button" value="取消" class="quxiao"  />
               </li>
            </ul>
        </div>
	    <div class="clear"></div>
        <!--修改弹出窗口-->
<!--         <div class="yunBei"></div> -->
        <div class="tanShang1_1">
           <h3>修改抽奖活动</h3>
           <ul class="daiJingW">
                <li class="clearfix">
                   <span class="daiJing">活动名称</span>
                   <input type="text" name="rafflename1" value="" placeholder="请输入活动名称" class="activity-name"/>
                   <input type="hidden" name="aid" value=""/>
                </li>
                <li class="clearfix">
                   <span class="daiJing">总金额</span>
                   <input type="text" name="amount1" value="" placeholder="请输入活动总金额" />
                   <input type="hidden" name="old_amount" value=""/>
                </li>
                <li class="clearfix">
                   <span class="daiJing">活动类型</span>
                   <select name="type1" id="type1" class="activity-name" >
                        <option value="0">请选择活动类型</option>                       
                        <option value="1">现金直减</option>
                        <option value="2">抽代金券</option>
                    </select>
                </li>
                <li class="clearfix" style="display:none;">
                   <span class="daiJing">活动形式</span>
                   <select name="form1" id="form1"  class="activity-name">
                        <option value="0">请选择活动形式</option>                       
                        <option value="1" selected="selected">大转盘</option>
                    </select>
                </li>
                <li class="clearfix">
                   <span class="daiJing">开始日期</span>
                   <input type="text" name="start_date1" id="demoTime3" value="<?php echo date('Y-m-d H:i:s');?>"  placeholder="请选择活动开始日期" class="riqi activity-name" readonly />
                </li>
                <li class="clearfix">
                    <span class="daiJing">截止日期</span>
                    <input type="text" name="end_date1" id="demoTime4"  value="<?php echo date('Y-m-d H:i:s');?>" placeholder="请选择活动结束日期"  class="riqi activity-name" readonly />
                </li>
                <li class="clearfix closing_date1" style="display:none;">
                    <span class="daiJing">代金券截止日期</span>
                    <input type="text" name="coupon_end_date1" id="demoTime6"  value="<?php echo date('Y-m-d');?>" placeholder="请选择代金券结束日期"  class="riqi activity-name" readonly />
               </li>
                <li class="clearfix">
                   <span class="daiJing">所属公司</span>
                   <select name="bc_city1" id="bc_city1" >
                                <foreach name="bc_list" item="v" key="k" >
                                  <option value="{$k}" >{$v}</option>
                                </foreach>
                            </select>
                </li>
               <li class="clearfix">
                   <input type="button" id="eidtRaffle" value="确定" class="queding" />
                   <input type="button" value="取消" class="quxiao" />
               </li>
            </ul>
        </div>
       <div class="clear"></div>
        <div class="new-draw-popup" style='display:none;'>
          <h3>设置抽奖活动</h3>
          <div class="popup-hidden">
          <form id='set_rf' action="/Raffle/build_card" method="POST">
          <input type="hidden" name='ac_id' id="ac_id" value="">
             <table class="table" id="set_raffle">                                        
              <thead>
                <tr>
                  <th width="15%">活动余额</th>
                    <th>奖券面值(元)</th>
                    <th>奖金数量</th>
                    <th>设置时间</th>
                    <th>操作</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td></td>
                  <td><input type="hidden" name="price[]" value="2000"><select name='denomination' onchange="select_give_input(this)"><option>2000</option><option>1000</option><option>500</option><option>300</option><option>100</option></select></td>
                  <td><input type="text" name='num[]' value="" /></td>
                  <td></td>
                  <td><a class="added-btn1" onclick="addedBtn(this)"></a></td>
                </tr>
              </tbody>
            </table>
          </form>
          </div>
          <div class="popup-cont-btn">
            <input type="hidden" name="surplus_money" value="">
            <input type="button" value="确定" class="queding" id="raffle_submit">
            <input type="button" value="取消" class="quxiao" id="raffle_cancel">
          </div>
        </div>
        <script type="text/javascript">
          $(function(){
            var oHeight=$(".new-draw-popup").outerHeight();
            $(".new-draw-popup").css("marginTop",-oHeight/2+"px");
          })
          function addedBtn(obj){   
            var balance=parseInt($(obj).parents("tr").find("td").eq(0).html()); 
            if($(obj).parent().siblings().find("input").eq(1).val()==""||$(obj).parent().siblings().find("input").eq(1).val()==0){
              $(obj).parent().siblings().find("input").eq(1).css("border","solid 1px #f00");
              return false;
            }
            if($(obj).parents("tr").find("td").eq(0).html()==0){
              return false;
            }
            var selectIndex=$(obj).parent().siblings().find("select option:selected").val();
            var inputVal=$(obj).parent().siblings().find("input").eq(1).val();  
            if(balance<parseInt(selectIndex)*parseInt(inputVal)){
              $(obj).parent().siblings().find("input").css("border","solid 1px #f00");
              return false;
            }
            $(obj).hide();
            $(obj).parent().siblings().find("input").eq(1).css("border","solid 1px #d2d2d2");
            $(obj).parents("tr").find("td").eq(0).html(balance);
            $(obj).parent().siblings().find("select").attr('disabled',true);
            $(obj).parent().siblings().find("input").eq(1).attr('readonly',true);
            $(obj).parent().prev().html("<input type='text' name='createtime[]' value='"+startTime()+"' style='width:140px;' readonly />");
            $(obj).parent().html("<a class='added-btn2' onclick='reduceBtn(this)'></a>");
            // var htmlCurrent='<td>'+balance+'</td>'+'<td>'+selectIndex+'</td>'+'<td>'+inputVal+'</td>'+'<td><input type="text" value="'+startTime()+'" style="width:140px;" readonly /></td>'+'<td><a class="added-btn2" onclick="reduceBtn(this)"></a></td>';
            // $(obj).parents("tr").html(htmlCurrent);
            
            var oValue=balance-parseInt(selectIndex)*parseInt(inputVal);
            
            var htmlTr='<tr>'+'<td>'+oValue+'</td>'+'<td><input type="hidden" name="price[]" value="2000"><select name="denomination" onchange="select_give_input(this)"><option>2000</option><option>1000</option><option>500</option><option>300</option><option>100</option></select></td>'+
                  '<td><input type="text" name="num[]" value="" /></td>'+'<td></td>'+'<td>'+'<a class="added-btn1" onclick="addedBtn(this)"></a></td>'
                  '</tr>';
            $(".new-draw-popup .table tbody").append(htmlTr);
            var oHeight=$(".new-draw-popup").outerHeight();
            $(".new-draw-popup").css("marginTop",-oHeight/2+"px");
          }

          function reduceBtn(obj1){ 
            var htmlTr1=parseInt($(obj1).parents("tr").find("select option:selected").val());
            var htmlTr2=parseInt($(obj1).parents("tr").find("input").eq(1).val());  
            var delValue=htmlTr1*htmlTr2;
            
            $(obj1).parents("tr").nextAll().each(function(){
              var firstValue=$(this).find("td").eq(0);
              firstValue.html(parseInt(firstValue.html())+delValue);
            })
            $(obj1).parents("tr").remove();
            
          }

          //当前时间
          function startTime(){
              var oDate=new Date();
              var n=oDate.getFullYear();
              var y=oDate.getMonth()+1;
              var r=oDate.getDate();
              var h=oDate.getHours();
              var f=oDate.getMinutes();
              var m=oDate.getSeconds();
              y=checkTime(y);
              h=checkTime(h);
              f=checkTime(f);
              m=checkTime(m);
              return n+"-"+y+"-"+r+" "+h+":"+f+":"+m;
            } 
          function checkTime(i){
            if(i<10){
              return "0"+i;
            }else{
              return i;
            }
          }
          $(document).ready(function() {  
              $("#set_raffle select").css("color","#333");
              $("#set_raffle select").find("option").css("color","#333");
              $("#set_raffle select").each(function() {
                  $(this).change(function(){
                       var selectIndex = $(this).get(0).selectedIndex;
                       if(selectIndex==0){             
                             $(this).css("color","#333");
                             $("#comeFrom").css("color","#333");
                             $(this).find("option").css("color","#333");
                          }else{
                             $(this).css("color","#333");
                       }      
                 })
              });
          });
          function select_give_input(obj){
              $(obj).siblings('input').val($(obj).val());
          }
        function set_raffle_card(aid){
          $(".yunBei").css("display","block");
          $(".new-draw-popup").fadeIn();
          $.get("/Raffle/get_build_card_log/aid/"+aid,function(data){
              if (data == 'null') {
                $(".surplus_money").val(parseInt($('#amount_'+aid).html()));
                $("#set_raffle tbody tr:last td").eq(0).html(parseInt($('#amount_'+aid).html()));
                $("#ac_id").val(aid);
              }else{
                var dataObj=eval("("+data+")");
                var tbody = "";
                var last_surplus_money = parseInt($('#amount_'+aid).html());
                var last_denomination = 0;
                var last_num = 0;
                $.each(dataObj, function (n, value) {
                    last_surplus_money = parseInt(value.surplus);
                    last_denomination = parseInt(value.denomination);
                    last_num = parseInt(value.num);
                    tbody += "<tr><td>"+parseInt(value.surplus)+"</td><td>"+value.denomination+"</td><td>"+value.num+"</td><td>"+value.createtime+"</td></tr>";
                  });
                $("#set_raffle tbody").prepend(tbody);
                $("#ac_id").val(aid);
                $(".surplus_money").val(last_surplus_money - last_denomination*last_num);
                $("#set_raffle tbody tr:last td").eq(0).html(last_surplus_money - last_denomination*last_num);
              }
          });
      }

       $("#raffle_submit").click(function(){
        var selectInput = $("#set_raffle tbody tr:last td").find('input').eq(1);
        var selectNun = selectInput.val();
        // if (selectNun < 1) {
        //     selectInput.css("border","solid 1px #f00");
        //     return false;
        // };
        var selectMoney=$("#set_raffle tbody tr:last td").find("select option:selected").val();
        var lastBalance = $("#set_raffle tbody tr:last td").eq(0).html();
            if(parseInt(lastBalance)<parseInt(selectMoney)*parseInt(selectNun)){
              selectInput.css("border","solid 1px #f00");
              return false;
            }
        $("#raffle_submit").attr("disabled", "disabled").css({"background": "#999", "border": "none", "color": "#fff"}).val("提交中...");
        // post_submit_json('set_rf',function(data){
        //     //成功回调
        //     delay_alert('设置成功',300);
        //     setTimeout(function(){
        //         //window.location.reload(); 
        //         $("#raffle_submit").val("确定").removeAttr("disabled style");  
        //         location.href='/raffle/index';
        //     },300);
        // });
        var fm =$('#set_rf');
        var post_data = $(fm).serialize();
        $.post("/Raffle/build_card",post_data,function(res){
            if(res.code=='200'){
                delay_alert('设置成功');
                setTimeout(function(){
                //window.location.reload(); 
                $("#raffle_submit").val("确定").removeAttr("disabled style");  
                location.href='/raffle/index';
            },300);
            }else{
                delay_alert(res.msg); 
                $("#raffle_submit").val("确定").removeAttr("disabled style");  
            }
        },'json');
      });

      $("#raffle_cancel").click(function(){
          $(".yunBei").css("display","none");
          $(".new-draw-popup").fadeOut();
          window.location.reload(); 
       });
    </script>

        <div class="clear"></div> 
        <div class="tanShang3">
           <h3></h3>
           <ul class="daiJingW">
                <div  style="height:100px;font-size:25px;line-height:100px;text-align: center;">
                    抽奖活动已新建成功
                 </div>
                 <input type="hidden" id='raffle_id' value="0">
                <li class="clearfix" style="margin-left:30px">
                    <input type="button" value="去设置活动面值" class="shezhi" />
                    <input type="button" value="暂不设置" class="bushezhi" />
                </li>
            </ul>
        </div>
        <div class="clear"></div> 
        <!-- <div class="draw-tanShang4" style="display: none;">
           <h3>追加活动金额</h3>
           <ul class="daiJingW">
                <li class="additional-text clearfix"><span>活动金额：</span><i id="ac_amount">元</i></li>
                <li class="additional-text clearfix"><span>追加活动金额：</span><input type="text" name='additional_activity' id="additional_activity" value="" /><i>元</i></li>
                <input type="hidden" name='activity_id' id="activity_id" value="">
                <li class="clearfix" style="margin-left:30px">
                    <input type="button" value="确定" class="additional-btn1" />
                    <input type="button" value="取消" class="additional-btn2" />
                </li>
            </ul>
        </div> -->
        <div class="clear"></div> 
	</div>
</div>
<script type="text/javascript">
	get_list();
	function get_list(){
        var url = mkurl();
	    $.get(url,function(data){
	    	$("#listBox").html(data);
	    },"html");
	}

	function get_page(p){
        var url = mkurl();
	    $.get(url, {'p':p}, function(data){
	    	$("#listBox").html(data);
	    },"html");
	}

    //搜索
    $("#searchBtn").on('click',function(){
        var url = mkurl();
        $.get(url,function(data){
   	    	$("#listBox").html(data);
   	    },"html");
    });
    function mkurl(){
        var url = '/Raffle/raffle_list';
        var start_time = $('#start_time').val();
        if(start_time){
            url += '/start_time/'+start_time;
        }

        var end_time = $('#end_time').val();
        if(end_time){
            url += '/end_time/'+end_time;
        }

        var bc_city = $('#cx_bc_city option:selected').val();
        if(bc_city){
            url += '/bc_city/'+bc_city;
        }
        var keyword = $('input[name=keyword]').val();
        if(keyword && keyword !="活动ID、活动金额、活动名称"){
            url += '/keyword/'+encodeURIComponent(keyword);
        }
        return url;
    }

    $(".shezhi").on('click',function(){
        window.location.reload(); 
        var raffle_id = $('#raffle_id').val();
        set_raffle_card(raffle_id);
        $('.tanShang3').hide();
        $(".yunBei").css("display","block");
        $(".new-draw-popup").fadeIn();  
    });
    $(".bushezhi").on('click',function(){
        $('.tanShang3').fadeOut();
        $(".yunBei").hide();
        location.reload();
    });
    $('.tanShang ul li .queding').on('click',function(){
        var rafflename = $('input[name=rafflename]').val();
        if(rafflename == ''){
            shibai_alert1('活动名称不能为空');
            return;
        }
        var amount = $('input[name=amount]').val();
        if(amount == ''){
            shibai_alert1('活动金额不能为空');
            return;
        }
        var re = /^[1-9]+[0-9]*]*$/;
        if (!re.test(amount)) {
            shibai_alert1('活动金额只能为正整数');
            return;
        } 
        var type = $('#type option:selected') .val();
        if (type < 1) {
            shibai_alert1('请选择活动类型');
            return;
        };
        var form = $('#form option:selected') .val();
        if (form < 1) {
            shibai_alert1('请选择活动形式');
            return;
        };
        var start_date = $('input[name=start_date]').val();
        if(start_date == ''){
            shibai_alert1('开始日期不能为空');
            return;
        }
        var end_date = $('input[name=end_date]').val();
        if(end_date == ''){
            shibai_alert1('结束日期不能为空');
            return;
        }
        if (start_date >= end_date) {
            shibai_alert1('开始日期不能大于等于结束日期');
            return;
        };
        if (type == 2) {
            var coupon_end_date = $('input[name=coupon_end_date]').val();
            if (coupon_end_date == '') {
                shibai_alert1('代金券截止日期不能为空');
                return;
            }
            if (end_date > coupon_end_date+" 23:59:59") {
                shibai_alert1('代金券截止日期应不小于活动结束时间');
                return;
            }
        };
        
        var bc_city = $('#bc_city').val();
        if (bc_city == '') {
            shibai_alert1('活动所属公司不能为空');
            return;
        };
        var param={
            'rafflename':rafflename,
            'amount':amount,
            'type':type,
            'form':form,
            'start_date':start_date,
            'end_date':end_date,
            'coupon_end_date':coupon_end_date,
            'bc_city':bc_city
        };
        var btn = $("#addRaffle");
        btn.attr("disabled", "disabled").css({"background": "#999", "border": "none"}).val("提交中...");
        $.post("/Raffle/add_raffle",param,function(data){
            if(data.code=='200'){
                // $('.tanShang').hide();
                // $('.yunBei').hide();
                // btn_alert(data.msg,1000);
                delay_alert('添加成功',200);
                setTimeout(function(){
                btn.removeAttr("disabled style").val("确定");
                window.location.reload(); 
            },300);
                // $('.tanShang3').show();
            }else{
                shibai_alert1(data.msg);
                btn.removeAttr("disabled style").val("确定");
            }

        },'json');
    });

$("#demoTime1").ymdateplugin({
        showTimePanel: true,
        changeMonth: true,
        changeYear: true
    }); 
$("#demoTime2").ymdateplugin({
        showTimePanel: true,
        changeMonth: true,
        changeYear: true
    });
$("#demoTime3").ymdateplugin({
        showTimePanel: true,
        changeMonth: true,
        changeYear: true
    });
$("#demoTime4").ymdateplugin({
        showTimePanel: true,
        changeMonth: true,
        changeYear: true
    });
$("#start_time").ymdateplugin({
        changeMonth: true,
        changeYear: true
    });
$("#end_time").ymdateplugin({
        changeMonth: true,
        changeYear: true
    });
$("#demoTime5").ymdateplugin({
        // showTimePanel: true,
        changeMonth: true,
        changeYear: true
    }); 
$("#demoTime6").ymdateplugin({
         // showTimePanel: true,
        changeMonth: true,
        changeYear: true
    }); 
$(document).ready(function() {

    var tanTop=$(".tanShang1_1").height();
    $(".tanShang1_1").css("marginTop",-tanTop/2);


  $("#type").change(function(){             
    if($(this).get(0).selectedIndex==2){                
      $(".closing_date").css("display","block");
       var tanTop=$(".tanShang").height();   
     $(".tanShang").css("marginTop",-tanTop/2);
    }else{
       $(".closing_date").css("display","none");
       var tanTop=$(".tanShang").height();   
     $(".tanShang").css("marginTop",-tanTop/2);
    }
  })

  $("#type1").change(function(){             
    if($(this).get(0).selectedIndex==2){                
      $(".closing_date1").css("display","block");
       var tanTop=$(".tanShang1_1").height();   
     $(".tanShang1_1").css("marginTop",-tanTop/2);
    }else{
       $(".closing_date1").css("display","none");
       var tanTop=$(".tanShang1_1").height();   
     $(".tanShang1_1").css("marginTop",-tanTop/2);
    }
  })
    // var aaaa  = false;
    // $(".luckDraw").delegate("#luck-jia", "click", function(){
    //     if (aaaa) {
    //       return;
    //     };
    //     aaaa   = true;
    //     var oText=$(this).parent().siblings("em").eq(0).html();                                     
    //     var oText1=$(this).parent().siblings("em").eq(1).find("select").val();                  
    //     var oText2=$(this).parent().siblings("em").eq(2).find("input").val();
    //     if(oText1==""){                     
    //         $(this).parent().siblings("em").eq(1).find("input").css("border","solid 1px red");                      
    //     }else if(oText2==""){
    //         $(this).parent().siblings("em").eq(1).find("input").css("border","solid 1px #d2d2d2");      
    //         $(this).parent().siblings("em").eq(2).find("input").css("border","solid 1px red");
    //     }else if(oText2*oText1 > oText){
    //         shibai_alert1("活动余额不足，请重新选择");
    //         return;
    //     }
    //     else{

    //         $('#luck-jia').addClass('luck-hui').removeClass('luck-jia');
    //         $(this).parent().siblings("em").eq(2).find("input").css("border","solid 1px #d2d2d2");
    //         var aid = $('#set_aid').val();
    //         var param = {
    //             'num':oText2,
    //             'price':oText1
    //         };
    //         $.post("/Raffle/create_card/aid/"+aid,param,function(data){
    //             var data=eval("("+data+")");
    //             if(data.code=='200'){
    //                 set_raffle_card1(aid);
    //                 $('#luck-jia').addClass('luck-jia').removeClass('luck-hui');
    //                 aaaa = false;
    //             }else{
    //                 shibai_alert1(data.msg);
    //                 $('#luck-jia').addClass('luck-jia').removeClass('luck-hui');
    //                 aaaa = false;
    //             }
    //         })

    //         // total=parseInt(oText-oText1*oText2);
    //         // $(this).parent().siblings("em").eq(0).html(total);
    //         // $(this).parent().siblings("em").eq(1).find("input").val("");    
    //         // $(this).parent().siblings("em").eq(2).find("input").val("");                
    //         // $(this).parent().parent().before('<li><em>'+total+'</em>'+'<em class="luck-lottery">'+oText1+'</em>'+'<em>'+oText2+'</em></li>');
    //     }
    //     var tanTop=$(".tanShang2").height();
    //     $(".tanShang2").css("marginTop",-tanTop/2);
    // })
    $("select").css("color","#333");
    $("select").find("option").css("color","#333");
    $("select").each(function() {
        $(this).change(function(){
             var selectIndex = $(this).get(0).selectedIndex;
             if(selectIndex==0){             
                   $(this).css("color","#333");
                   $("#comeFrom").css("color","#333");
                   $(this).find("option").css("color","#333");
                }else{
                   $(this).css("color","#333");
             }      
       })
    });
});

$(".tanShang1_1 ul li .quxiao").click(function(){
  $(".tanShang1_1").fadeOut();
  $(".yunBei").css("display","none");
  window.location.reload(); 
})

// function set_activity_amount(a_id){
//   var ac_amount = $('#amount_'+a_id).html();
//   $('#ac_amount').html(ac_amount);
//   $("#activity_id").val(a_id);
//   $(".yunBei").css("display","block");
//   $(".draw-tanShang4").fadeIn();
// }

// $(".additional-btn1").click(function(){
//     var a_id = $('#activity_id').val();
//     var amount = $('#additional_activity').val();
//     if (isNaN(amount)) {
//         shibai_alert1("追加活动金额不合法");
//         return;
//     };
//     var param = {
//         'a_id':a_id,
//         'amount':amount
//     };
//     var btn = $(".additional-btn1");
//     btn.attr("disabled", "disabled").css({"background": "#999", "border": "none"}).val("提交中...");
//     $.post("/Raffle/add_activity_amount",param,function(data){
//         var data=eval("("+data+")");
//         if(data.code=='200'){
//            $('.draw-tanShang4').hide();
//             $('.yunBei').hide();
//             btn.removeAttr("disabled style").val("确定");
//             btn_alert(data.msg,2000,function(){window.location.reload()});
//         }else{
//             shibai_alert1(data.msg);
//             btn.removeAttr("disabled style").val("确定");
//         }
//     })
// })


// $(".additional-btn2").click(function(){
//   $("#activity_id").attr("value","");
//   $(".additional_activity").attr("value","");
//   $(".draw-tanShang4").fadeOut();
//   $(".yunBei").css("display","none");
// });

</script>
<include file="Public/foot" />
